/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.banconacion.servlet;

import com.banconacion.bean.SolicitudAperturaDTO;
import com.banconacion.service.SolicitudAperturaService;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.Date;

/**
 *
 * @author Ernesto
 */
public class GenerarSolicitudServlet extends HttpServlet {
    private static final long serialVersionUID = 2652225997622140246L;
    
    protected void service(
            HttpServletRequest request,
            HttpServletResponse response)
            throws ServletException, IOException {
        SolicitudAperturaService aperturaService = new SolicitudAperturaService();
        
        int codigoCliente = Integer.parseInt(request.getParameter("codigoCliente"));
        String motivo = request.getParameter("txtMotivo");
        java.util.Date fa = new java.util.Date();
        Date fechaActual = new Date(fa.getYear(), fa.getMonth(), fa.getDay());
        
        SolicitudAperturaDTO aperturaDTO = new SolicitudAperturaDTO(0, fechaActual, motivo, codigoCliente);
        
        try {
            aperturaService.guardarSolicitud(aperturaDTO);
        } catch (Exception e) {
            
        }
        
        request.getRequestDispatcher("pages/MenuEncargado.jsp").forward(request, response);
    }
}
